package com.example.mapper;

import com.example.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface StudentMapper {

    List<Student> selectAll(Student student);

    @Insert("insert into student (student_id, student_number, student_name, class_id) VALUES (#{studentId},#{studentNumber},#{studentName},#{classId})")
    void insert(Student student);

    @Update("update student set student_name=#{studentName},student_number=#{studentNumber},class_id=#{classId} where student_id=#{studentId}")
    void update(Student student);

    @Delete("delete from student where student_id=#{studentId}")
    void delete(Integer studentId);

    @Select("select count(*) from student where class_id=#{classId}")
    int countByClassId(Integer classId);

    @Select("select count(*) from student where student_number=#{studentNumber}")
    int countByNumber(String studentNumber);

    @Select("select * from student where student_id=#{studentId}")
    Student selectById(Integer studentId);
}
